package com.java;

import java.util.Scanner;

import com.java.context.AuthContext;
import com.java.controller.LoginController;
import com.java.controller.StudentController;

public class Entry {
	
	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {
		LoginController loginController = new LoginController();
		StudentController studentController = new StudentController();
		System.out.println("***********************************************");
		System.out.println("************                      *************");
		System.out.println("************    欢迎登录学员管理系统        *************");
		System.out.println("************                      *************");
		System.out.println("***********************************************");

		System.out.println("");
		System.out.println("");
		
		
		while (true) {
			if (!AuthContext.isLogin()) {
				loginController.login();
			}
			System.out.println("请选择操作：");
			System.out.println("1.新增学员");
			System.out.println("2.编辑学员");
			System.out.println("3.删除学员");
			System.out.println("4.查询学员");
			System.out.println("5.打印所有学员");
			System.out.println("6.保存至文件");	//map 中实现
			System.out.println("7.加载文件中的对象");//map 中实现
			System.out.println("8.退出");
			
			int operate;
			try {
				operate = Integer.valueOf(scanner.nextLine());
			} catch (Exception e) {
				System.out.println("请选择正确的操作...");
				continue;
			}
			
			switch (operate) {
			case 1:
				studentController.add();
				break;
			case 2:
				studentController.edit();
				break;
			case 3:
				studentController.delete();
				break;
			case 4:
				studentController.find();
				break;
			case 5:
				studentController.print();
				break;
			case 6:
				studentController.save();
				break;
			case 7:
				studentController.load(); 
				break;
			case 8:
				loginController.logout();
				break;
			default:
				System.out.println("请选择正确的操作...");
				break;
			}
		}
	}
	
}
